#Twisted Shootout
#Copyright (C) 2007  Han Dao
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

#You can contact the author at wikipediankiba@gmail.com
import main
import gamemode
import pygame
import os
import data
import gamemenuoptions
import loadmenu
import gamemenucollide
class GameMenu:
	def __init__(self):
		self.data = data.read
		self.options = gamemenuoptions.GameMenuOptions()
		self.options.activate()
		self.collide = gamemenucollide.GameMenuCollide(self.options)
		self.load = loadmenu.LoadMenu()
	def run(self):
		name, image = self.data.load("main")
		main.display.blit(image,(0,0))
		while 1:
			pygame.display.flip()
			for e in pygame.event.get():
			      if e.type == pygame.QUIT:
				      return
			      if e.type == pygame.KEYDOWN:
				      if e.key == pygame.K_ESCAPE:
					      return
				      elif e.key == pygame.K_RETURN:
					      game.run()
			      if e.type == pygame.MOUSEBUTTONDOWN:
				      pos = pygame.mouse.get_pos()
				      key = pygame.Rect(pos[0],pos[1],1,1)
				      self.effect(key)
			self.draw()
	def effect(self,key):
		a = self.collide.menu(key)
		if a == 1:
			self.load.run(main.display)
			self.game = gamemode.GameMode(self.load.options.name)
			self.game.run()
	def draw(self):
		self.options.sprites.draw(main.display)